package com.dq.security.exception;


import com.dq.security.exception.common.CommonError;

/**
 * @ClassName: CommonException
 * @Description: 自定义异常
 * @Author: Practical-training-projects_小强 (QQ:2680825683)
 * @Since: 2023/5/11 14:07
 */
public class CommonException extends RuntimeException {
    private String errorMsg;

    private CommonException() {
        super();
    }

    public CommonException(String message) {
        super(message);
        this.errorMsg = message;
    }

    public String getErrMessage() {
        return this.errorMsg;
    }

    //正常抛出
    public static void cast(String message) {
        throw new CommonException(message);
    }

    //枚举抛出
    public static void cast(CommonError commonError) {
        throw new CommonException(commonError.getErrMessage());
    }
}
